package controllers

import (
	"fmt"
	"github.com/gin-gonic/gin"
	bizcode "mall-api-gin/pkg/bizerror"
	"mall-api-gin/pkg/e"
	"mall-api-gin/service"
	"net/http"
)

type UserController struct {
	BaseController
}

func (con UserController) Index(ctx *gin.Context) {
	defer con.PanicHandler(http.StatusOK)
	con.C = ctx
	list, total, err := service.UserService.Paginate(1, 10)
	if err != nil {
		con.ErrResponse(http.StatusOK, e.ErrorDb, fmt.Sprintf("err: %v", err))
	}
	con.Response(http.StatusOK, bizcode.SUCCESS, gin.H{
		"list":  list,
		"total": total,
	})
}
